package com.everest.tribalapp;



import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class SQLiteAdapter_DesaPinter {

	public static final String MYDATABASE_NAME = "tribal_app_2";
	public static final String MYDATABASE_TABLE = "desa_pinter";
	public static final int MYDATABASE_VERSION = 1;
	public static final String KEY_ID = "_id";
	public static final String F1_1 = "f1_1";
	public static final String F1_2 = "f1_2";
	public static final String F1_3 = "f1_3";
	public static final String F1_4 = "f1_4";
	public static final String F1_5 = "f1_5";
	public static final String F1_6 = "f1_6";
	public static final String F2_1 = "f2_1";
	public static final String F2_2 = "f2_2";
	public static final String F2_3 = "f2_3";
	public static final String F2_4 = "f2_4";
	public static final String F2_5 = "f2_5";
	public static final String F2_6a = "f2_6a";
	public static final String F2_6b = "f2_6b";
	public static final String F3_1a = "f3_1a";
	public static final String F3_1b = "f3_1b";
	public static final String F3_211 = "f3_211";
	public static final String F3_212 = "f3_212";
	public static final String F3_213 = "f3_213";
	public static final String F3_214 = "f3_214";
	public static final String F3_215 = "f3_215";
	public static final String F3_221 = "f3_221";
	public static final String F3_222 = "f3_222";
	public static final String F3_223 = "f3_223";
	public static final String F3_224 = "f3_224";
	public static final String F3_225 = "f3_225";
	public static final String F3_231 = "f3_231";
	public static final String F3_232 = "f3_232";
	public static final String F3_233 = "f3_233";
	public static final String F3_234 = "f3_234";
	public static final String F3_235 = "f3_235";
	public static final String F3_3 = "f3_3";
	public static final String F3_4 = "f3_4";
	public static final String F3_5a = "f3_5a";
	public static final String F3_5b = "f3_5b";
	public static final String F3_5c = "f3_5c";
	public static final String F3_5d = "f3_5d";
	public static final String F4_1 = "f4_1";
	public static final String F4_2 = "f4_2";
	public static final String F4_3 = "f4_3";
	public static final String F4_4 = "f4_4";
	public static final String F4_5 = "f4_5";
	public static final String F4_6 = "f4_6";
	public static final String F4_7 = "f4_7";
	public static final String F4_8 = "f4_8";
	public static final String F4_9a = "f4_9a";
	public static final String F4_9b = "f4_9b";
	public static final String F4_9c = "f4_9c";
	public static final String F4_10 = "f4_10";
	public static final String F4_11a = "f4_11a";
	public static final String F4_11b = "f4_11b";
	public static final String F4_12a = "f4_12a";
	public static final String F4_12b = "f4_12b";
	public static final String F4_13 = "f4_13";
	public static final String F4_14a = "f4_14a";
	public static final String F4_14b = "f4_14b";
	public static final String F4_15 = "f4_15";
	public static final String F4_16 = "f4_16";
	public static final String F4_17 = "f4_17";
	public static final String F4_18 = "f4_18";
	public static final String F4_19a = "f4_19a";
	public static final String F4_19b = "f4_19b";
	public static final String F4_20a = "f4_20a";
	public static final String F4_20b = "f4_20b";
	public static final String F4_20c = "f4_20c";
	public static final String F4_20d = "f4_20d";
	public static final String F5_1 = "f5_1";
	public static final String F5_2 = "f5_2";
	public static final String F5_3 = "f5_3";
	public static final String F5_4 = "f5_4";
	public static final String F5_5a = "f5_5a";
	public static final String F5_5b = "f5_5b";
	public static final String F5_5c = "f5_5c";
	public static final String F5_5d = "f5_5d";
	public static final String F5_6 = "f5_6";
	public static final String F5_7a = "f5_7a";
	public static final String F5_7b = "f5_7b";
	public static final String F5_8 = "f5_8";
	public static final String F5_9a = "f5_9a";
	public static final String F5_9b = "f5_9b";
	public static final String F5_9c = "f5_9c";
	public static final String F5_9d= "f5_9d";
	public static final String F5_10 = "f5_10";
	public static final String F5_11 = "f5_11";
	public static final String F5_12 = "f5_12";
	public static final String F5_13a = "f5_13a";
	public static final String F5_13b = "f5_13b";
	public static final String F6_1 = "f6_1";
	public static final String F6_2 = "f6_2";
	public static final String F6_3 = "f6_3";
	public static final String F7_1 = "f7_1";
	public static final String F7_2 = "f7_2";
	public static final String F7_3 = "f7_3";
	public static final String F7_4 = "f7_4";
	public static final String F7_5 = "f7_5";
	public static final String F7_6 = "f7_6";
	public static final String F7_7 = "f7_7";
	public static final String F7_8 = "f7_8";
	public static final String F7_YEAR = "f7_year";
	private static final String SCRIPT_CREATE_DATABASE =
		"create table " + MYDATABASE_TABLE + " ("
		+ KEY_ID + " integer primary key autoincrement, "+ F1_1 + " text, "+ F1_2 + " text, "+ F1_3 + " text, "+ F1_4 + " text, "+ F1_5 + " text, "+ F1_6 + " text, "+ F2_1 + " text, "+ F2_2 + " text, "+ F2_3 + " text, "+ F2_4 + " text, "+ F2_5 + " text, "+ F2_6a + " text, "+ F2_6b + " text, "+ F3_1a + " text, "+ F3_1b + " text, "+ F3_211 + " text, "+ F3_212 + " text, "+ F3_213 + " text, "+ F3_214 + " text, "+ F3_215 + " text, "+ F3_221 + " text, "+ F3_222 + " text, "+ F3_223 + " text, "+ F3_224 + " text, "+ F3_225 + " text, "+ F3_231 + " text, "+ F3_232 + " text, "+ F3_233 + " text, "+ F3_234 + " text, "+ F3_235 + " text, "+ F3_3 + " text, "+ F3_4 + " text, "+ F3_5a + " text, "+ F3_5b + " text, "+ F3_5c + " text, "+ F3_5d + " text, "+ F4_1 + " text, "+ F4_2 + " text, "+ F4_3 + " text, "+ F4_4 + " text, "+ F4_5 + " text, "+ F4_6 + " text, "+ F4_7 + " text, "+ F4_8 + " text, "+ F4_9a + " text, "+ F4_9b + " text, "+ F4_9c + " text, "+ F4_10 + " text, "+ F4_11a + " text, "+ F4_11b + " text, "+ F4_12a + " text, "+ F4_12b + " text, "+ F4_13 + " text, "+ F4_14a + " text, "+ F4_14b + " text, "+ F4_15 + " text, "+ F4_16 + " text, "+ F4_17 + " text, "+ F4_18 + " text, "+ F4_19a + " text, "+ F4_19b + " text, "+ F4_20a + " text, "+ F4_20b + " text, "+ F4_20c + " text, "+ F4_20d + " text, "+ F5_1 + " text, "+ F5_2 + " text, "+ F5_3 + " text, "+ F5_4 + " text, "+ F5_5a + " text, "+ F5_5b + " text, "+ F5_5c + " text, "+ F5_5d + " text, "+ F5_6 + " text, "+ F5_7a + " text, "+ F5_7b + " text, "+ F5_8 + " text, "+ F5_9a + " text, "+ F5_9b + " text, "+ F5_9c + " text, "+ F5_9d + " text, "+ F5_10 + " text, "+ F5_11 + " text, "+ F5_12 + " text, "+ F5_13a + " text, "+ F5_13b + " text, "+ F6_1 + " text, "+ F6_2 + " text, "+ F6_3 + " text, "+ F7_1 + " text, "+ F7_2 + " text, "+ F7_3 + " text, "+ F7_4 + " text, "+ F7_5 + " text, "+ F7_6 + " text, "+ F7_7 + " text, "+ F7_8 + " text, "+ F7_YEAR + " text);";
	
	private SQLiteHelper sqLiteHelper;
	private SQLiteDatabase sqLiteDatabase;
	private Context context;
	
	public SQLiteAdapter_DesaPinter(Context c)
	{
		context = c;
	}
	
	public SQLiteAdapter_DesaPinter openToRead() throws android.database.SQLException 
	{
		sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null, MYDATABASE_VERSION);
		sqLiteDatabase = sqLiteHelper.getReadableDatabase();
		return this;	
	}
	
	public SQLiteAdapter_DesaPinter openToWrite() throws android.database.SQLException 
	{
		sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null, MYDATABASE_VERSION);
		sqLiteDatabase = sqLiteHelper.getWritableDatabase();
		return this;	
	}
	
	public void close()
	{
		sqLiteHelper.close();
	}
	
	public long insert(String desa_F1_1,String desa_F1_2,String desa_F1_3,String desa_F1_4,String desa_F1_5,String desa_F1_6,
			String desa_F2_1,String desa_F2_2,String desa_F2_3,String desa_F2_4,String desa_F2_5,String desa_F2_6a,String desa_F2_6b,
			String desa_F3_1a,String desa_F3_1b,String desa_F3_211,String desa_F3_212,String desa_F3_213,String desa_F3_214,String desa_F3_215,String desa_F3_221,String desa_F3_222,String desa_F3_223,String desa_F3_224,String desa_F3_225,String desa_F3_231,String desa_F3_232,String desa_F3_233,String desa_F3_234,String desa_F3_235,String desa_F3_3,String desa_F3_4,String desa_F3_5a,String desa_F3_5b,String desa_F3_5c,String desa_F3_5d,
			String desa_F4_1,String desa_F4_2,String desa_F4_3,String desa_F4_4,String desa_F4_5,String desa_F4_6,String desa_F4_7,String desa_F4_8,String desa_F4_9a,String desa_F4_9b,String desa_F4_9c,String desa_F4_10,String desa_F4_11a,String desa_F4_11b,String desa_F4_12a,String desa_F4_12b,String desa_F4_13,String desa_F4_14a,String desa_F4_14b,String desa_F4_15,String desa_F4_16,String desa_F4_17,String desa_F4_18,String desa_F4_19a,String desa_F4_19b,String desa_F4_20a,String desa_F4_20b,String desa_F4_20c,String desa_F4_20d,
			String desa_F5_1,String desa_F5_2,String desa_F5_3,String desa_F5_4,String desa_F5_5a,String desa_F5_5b,String desa_F5_5c,	String desa_F5_5d,String desa_F5_6,String desa_F5_7a,String desa_F5_7b,String desa_F5_8,String desa_F5_9a,String desa_F5_9b,String desa_F5_9c,String desa_F5_9d,String desa_F5_10,String desa_F5_11,String desa_F5_12,String desa_F5_13a,String desa_F5_13b,
			String desa_F6_1,String desa_F6_2,String desa_F6_3,
			String desa_F7_1,String desa_F7_2,String desa_F7_3,String desa_F7_4,String desa_F7_5,String desa_F7_6,String desa_F7_7,String desa_F7_8,String y)
	{
		ContentValues contentValues = new ContentValues();
		contentValues.put("f1_1",desa_F1_1);
		contentValues.put("f1_2",desa_F1_2);
		contentValues.put("f1_3",desa_F1_3);
		contentValues.put("f1_4",desa_F1_4);
		contentValues.put("f1_5",desa_F1_5);
		contentValues.put("f1_6",desa_F1_6);
		contentValues.put("f2_1",desa_F2_1);
		contentValues.put("f2_2",desa_F2_2);
		contentValues.put("f2_3",desa_F2_3);
		contentValues.put("f2_4",desa_F2_4);
		contentValues.put("f2_5",desa_F2_5);
		contentValues.put("f2_6a",desa_F2_6a);
		contentValues.put("f2_6b",desa_F2_6b);
		contentValues.put("f3_1a",desa_F3_1a);
		contentValues.put("f3_1b",desa_F3_1b);
		contentValues.put("f3_211",desa_F3_211);
		contentValues.put("f3_212",desa_F3_212);
		contentValues.put("f3_213",desa_F3_213);
		contentValues.put("f3_214",desa_F3_214);
		contentValues.put("f3_215",desa_F3_215);
		contentValues.put("f3_221",desa_F3_221);
		contentValues.put("f3_222",desa_F3_222);
		contentValues.put("f3_223",desa_F3_223);
		contentValues.put("f3_224",desa_F3_224);
		contentValues.put("f3_225",desa_F3_225);
		contentValues.put("f3_231",desa_F3_231);
		contentValues.put("f3_232",desa_F3_232);
		contentValues.put("f3_233",desa_F3_233);
		contentValues.put("f3_234",desa_F3_234);
		contentValues.put("f3_235",desa_F3_235);
		contentValues.put("f3_3",desa_F3_3);
		contentValues.put("f3_4",desa_F3_4);
		contentValues.put("f3_5a",desa_F3_5a);
		contentValues.put("f3_5b",desa_F3_5b);
		contentValues.put("f3_5c",desa_F3_5c);
		contentValues.put("f3_5d",desa_F3_5d);
		contentValues.put("f4_1",desa_F4_1);
		contentValues.put("f4_2",desa_F4_2);
		contentValues.put("f4_3",desa_F4_3);
		contentValues.put("f4_4",desa_F4_4);
		contentValues.put("f4_5",desa_F4_5);
		contentValues.put("f4_6",desa_F4_6);
		contentValues.put("f4_7",desa_F4_7);
		contentValues.put("f4_8",desa_F4_8);
		contentValues.put("f4_9a",desa_F4_9a);
		contentValues.put("f4_9b",desa_F4_9b);
		contentValues.put("f4_9c",desa_F4_9c);
		contentValues.put("f4_10",desa_F4_10);
		contentValues.put("f4_11a",desa_F4_11a);
		contentValues.put("f4_11b",desa_F4_11b);
		contentValues.put("f4_12a",desa_F4_12a);
		contentValues.put("f4_12b",desa_F4_12b);
		contentValues.put("f4_13",desa_F4_13);
		contentValues.put("f4_14a",desa_F4_14a);
		contentValues.put("f4_14b",desa_F4_14b);
		contentValues.put("f4_15",desa_F4_15);
		contentValues.put("f4_16",desa_F4_16);
		contentValues.put("f4_17",desa_F4_17);
		contentValues.put("f4_18",desa_F4_18);
		contentValues.put("f4_19a",desa_F4_19a);
		contentValues.put("f4_19b",desa_F4_19b);
		contentValues.put("f4_20a",desa_F4_20a);
		contentValues.put("f4_20b",desa_F4_20b);
		contentValues.put("f4_20c",desa_F4_20c);
		contentValues.put("f4_20d",desa_F4_20d);
		contentValues.put("f5_1",desa_F5_1);
		contentValues.put("f5_2",desa_F5_2);
		contentValues.put("f5_3",desa_F5_3);
		contentValues.put("f5_4",desa_F5_4);
		contentValues.put("f5_5a",desa_F5_5a);
		contentValues.put("f5_5b",desa_F5_5b);
		contentValues.put("f5_5c",desa_F5_5c);
		contentValues.put("f5_5d",desa_F5_5d);
		contentValues.put("f5_6",desa_F5_6);
		contentValues.put("f5_7a",desa_F5_7a);
		contentValues.put("f5_7b",desa_F5_7b);
		contentValues.put("f5_8",desa_F5_8);
		contentValues.put("f5_9a",desa_F5_9a);
		contentValues.put("f5_9b",desa_F5_9b);
		contentValues.put("f5_9c",desa_F5_9c);
		contentValues.put("f5_9d",desa_F5_9d);
		contentValues.put("f5_10",desa_F5_10);
		contentValues.put("f5_11",desa_F5_11);
		contentValues.put("f5_12",desa_F5_12);
		contentValues.put("f5_13a",desa_F5_13a);
		contentValues.put("f5_13b",desa_F5_13b);
		contentValues.put("f6_1",desa_F6_1);
		contentValues.put("f6_2",desa_F6_2);
		contentValues.put("f6_3",desa_F6_3);
		contentValues.put("f7_1",desa_F7_1);
		contentValues.put("f7_2",desa_F7_2);
		contentValues.put("f7_3",desa_F7_3);
		contentValues.put("f7_4",desa_F7_4);
		contentValues.put("f7_5",desa_F7_5);
		contentValues.put("f7_6",desa_F7_6);
		contentValues.put("f7_7",desa_F7_7);
		contentValues.put("f7_8",desa_F7_8);
		contentValues.put("f7_year",y);
		return sqLiteDatabase.insert(MYDATABASE_TABLE, null, contentValues);
	}

	public int deleteAll()
	{
		return sqLiteDatabase.delete(MYDATABASE_TABLE, null, null);
	}
	public int delete(String  a)
	{
		return sqLiteDatabase.delete(MYDATABASE_TABLE, KEY_ID+"=?", new String[] {a});
	}
	
	public class SQLiteHelper extends SQLiteOpenHelper {

		public SQLiteHelper(Context context, String name,
				CursorFactory factory, int version) {
			super(context, name, factory, version);
		}

		@Override
		public void onCreate(SQLiteDatabase db)
		{
			db.execSQL(SCRIPT_CREATE_DATABASE);
		}

		@Override
		public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) 
		{

		}

	}
	
	public Cursor queue()
	{
		String[] columns = new String[]{KEY_ID,F1_1,F1_2,F1_3,F1_4,F1_5,F1_6,
				F2_1,F2_2,F2_3,F2_4,F2_5,F2_6a,F2_6b,
				F3_1a,F3_1b,F3_211,F3_212,F3_213,F3_214,F3_215,F3_221,F3_222,F3_223,F3_224,F3_225,F3_231,F3_232,F3_233,F3_234,F3_235,F3_3,F3_4,F3_5a,F3_5b,F3_5c,F3_5d,
				F4_1,F4_2,F4_3,F4_4,F4_5,F4_6,F4_7,F4_8,F4_9a,F4_9b,F4_9c,F4_10,F4_11a,F4_11b,F4_12a,F4_12b,F4_13,F4_14a,F4_14b,F4_15,F4_16,F4_17,F4_18,F4_19a,F4_19b,F4_20a,F4_20b,F4_20c,F4_20d,
				F5_1,F5_2,F5_3,F5_4,F5_5a,F5_5b,F5_5c,	F5_5d,F5_6,F5_7a,F5_7b,F5_8,F5_9a,F5_9b,F5_9c,F5_9d,F5_10,F5_11,F5_12,F5_13a,F5_13b,
				F6_1,F6_2,F6_3,
				F7_1,F7_2,F7_3,F7_4,F7_5,F7_6,F7_7,F7_8,F7_YEAR};
		
//		Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, null,null ,null, null, null, null);
		Cursor cursor = sqLiteDatabase.rawQuery("select * from desa_pinter",null);
		
		return cursor;
	}
	
	public int getRowCount()
	{
		String countQuery = "SELECT  * FROM " + MYDATABASE_TABLE ;
		Cursor cursor = sqLiteDatabase.rawQuery(countQuery, null);
		int rowCount = cursor.getCount();
		sqLiteDatabase.close();
		cursor.close();
		return rowCount;
	}
	
}
